package com.kx.game.center.local.request;

import java.util.Map;

/**
 * Local通用请求数据，从GS到中心服务器的通用请求数据，比如GameID,ServerID等
 * 
 * @author wenji.fan
 * @since 2013年8月6日
 * 
 */
public class LocalCommonRequestData {
	private static final String GAME_ID_KEY = "gameID";
	private static final String SERVER_ID_KEY = "serverID";

	/**
	 * 游戏ID
	 */
	private int gameID;

	/**
	 * 服务器ID
	 */
	private int serverID;

	/**
	 * 解析请求参数
	 * 
	 * @param parameters
	 * @return
	 */
	public static LocalCommonRequestData parse(Map<String, String> parameters) {
		if (!parameters.containsKey(GAME_ID_KEY)) {
			return null;
		}

		if (!parameters.containsKey(SERVER_ID_KEY)) {
			return null;
		}

		LocalCommonRequestData requestData = new LocalCommonRequestData();
		int gameID = Integer.parseInt(parameters.get(GAME_ID_KEY));
		int serverID = Integer.parseInt(parameters.get(SERVER_ID_KEY));
		requestData.setGameID(gameID);
		requestData.setServerID(serverID);
		return requestData;
	}

	public int getGameID() {
		return gameID;
	}

	public void setGameID(int gameID) {
		this.gameID = gameID;
	}

	public int getServerID() {
		return serverID;
	}

	public void setServerID(int serverID) {
		this.serverID = serverID;
	}

}
